<script>
	export default {
		methods: {
			phoneLogin(unionId) {
				uni.showLoading({
					mask: true,
					title: '登录中'
				});
				let params = {
					unionId: unionId
				}
				this.$H.post("user/unionIdLogin", params).then(res => {
					if (res.code == 0) {
						uni.setStorageSync("hasLogin", true);
						uni.setStorageSync("token", res.token);
					}
					uni.hideLoading();
				})
			},
		},
		onLaunch: function() {
			console.log('App Launch')
		},
		onShow: function() {
			console.log('App Show');
			let isLogin = uni.getStorageSync("hasLogin");
			const queryParam = this.$route.query;
			let unionId = queryParam.unionId;
			// console.log(queryParam.unionId); // 输出包含所有查询参数的对象
			if(!isLogin && unionId){
				this.phoneLogin(unionId);
			}
		},
		onHide: function() {
			console.log('App Hide')
		},
		onPageNotFound() {
			// 跳转到 404 页面：
			uni.redirectTo({
				url: "pages/error/error"
			});
		}
	}
</script>

<style lang="scss">
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	@import "uview-ui/index.scss";
	@import "static/css/iconfont.css";
</style>